package pzl.com.compositepattern;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;

import java.util.concurrent.FutureTask;

public class MainActivity extends AppCompatActivity {
    static final String TAG = "FolderComponent";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FileSystemComponent root = new FolderComponent("root");
        FileSystemComponent fun = new FolderComponent("娱乐");
        FileSystemComponent music = new FolderComponent("音乐");
        FileSystemComponent work = new FolderComponent("工作");

        root.add(fun);
        root.add(music);
        root.add(work);

        root.display();
        Log.w(TAG,"----------------------------------");

        FileSystemComponent mp31 = new FileComponent("醉赤壁.mp3");
        FileSystemComponent mp32 = new FileComponent("黑色毛衣.mp3");
        FileSystemComponent mp33 = new FileComponent("你不是真正的快乐.mp3");

        music.add(mp31);
        music.add(mp32);
        music.add(mp33);

        FileSystemComponent game1 = new FileComponent("星际争霸.exe");
        FileSystemComponent game2 = new FileComponent("守望先锋.exe");

        fun.add(game1);
        fun.add(game2);

        root.display();
        Log.w(TAG, "----------------------------------");

        root.remove(music);
        root.display();
    }

}
